﻿package mortal.game.view.common.tooltip.tooltips
{
    import com.mui.controls.*;
    import com.mui.display.*;
    import com.mui.utils.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import frEngine.pools.*;
    import frEngine.primitives.object2d.*;
    import frEngine.render.layer.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.manager.window3d.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.common.tooltip.tooltips.base.*;
    import mortal.game.view.firstReCharge.*;
    import mortal.game.view.vip.*;

    public class TooltipWing288 extends ToolTipScaleBg implements IWindow3D, IToolTip3D
    {
        protected var _3dBg:GImageBitmap;
        private var _3dName:GTextFiled;
        private var _3dDescItem:EffectItem;
        private var _tipsTxt:GImageBitmap;
        private var _bg:ScaleBitmap;
        private var _titleBg:GImageBitmap;
        private var _contentBmd:BitmapData;
        protected var _roleModelPlayer:UserModelPlayer;
        protected var _rect3d:Rect3DObject;
        protected var _img2d:Img2D;
        protected var _img2dTitle:Img2D;
        private var _3dBgx:int = 0;
        private var _3dBgy:int = 0;
        private var _isDisposed:Boolean;
        private var _wing288Data:Wing288Data;
        protected var _contentTopOf3DSprite:Sprite;

        public function TooltipWing288()
        {
            this._contentTopOf3DSprite = new Sprite();
            return;
        }// end function

        public function get contentTopOf3DSprite() : Sprite
        {
            return this._contentTopOf3DSprite;
        }// end function

        public function get contentContainer() : Sprite
        {
            return this;
        }// end function

        override public function get height() : Number
        {
            return 450;
        }// end function

        override public function get width() : Number
        {
            return 360;
        }// end function

        protected function createChildren() : void
        {
            this.updateSize(360, 410);
            this._isDisposed = false;
            this._3dBg = UIFactory.gImageBitmap(ImagesConst.VipTipsBg, 0, 0, null, this.update3DModule);
            this._bg = UIFactory.bg(0, 0, 360, 410, this, ImagesConst.ToolTipBgBai);
            this._titleBg = UIFactory.gImageBitmap("", 0, -10, this._contentTopOf3DSprite, this.drawTitle);
            this._3dDescItem = UICompomentPool.getUICompoment(EffectItem);
            this._3dDescItem.setItemStyle(ItemStyleConst.Small, null);
            this._3dDescItem.move(34, 232 - 208);
            this._contentTopOf3DSprite.addChild(this._3dDescItem);
            this._tipsTxt = UIFactory.gImageBitmap("", 4, 369, this._contentTopOf3DSprite, this.drawTitle);
            var _loc_1:* = GlobalStyle.textFormatBai.center();
            _loc_1.size = 18;
            this._3dName = UIFactory.gTextField("", 94, 238 - 208, 150, 35, this._contentTopOf3DSprite, _loc_1);
            this.dispatchEvent(new WindowEvent(WindowEvent.SHOW_END));
            this.addEventListener(Event.REMOVED_FROM_STAGE, this.removeFromeStageHandler);
            return;
        }// end function

        override public function set data(param1) : void
        {
            super.data = param1;
            this._wing288Data = param1;
            this.createChildren();
            var _loc_2:* = new ItemData(this._wing288Data.code);
            this._3dDescItem.itemData = _loc_2;
            this._3dName.htmlText = _loc_2.itemInfo.htmlName;
            this.updatePosition();
            return;
        }// end function

        protected function removeFromeStageHandler(event:Event) : void
        {
            this.removeEventListener(Event.REMOVED_FROM_STAGE, this.removeFromeStageHandler);
            this.dispatchEvent(new WindowEvent(WindowEvent.CLOSE_END));
            this._isDisposed = true;
            this._titleBg.dispose();
            this._titleBg = null;
            this._3dBg.dispose();
            this._3dBg = null;
            this._3dName.dispose();
            this._3dName = null;
            this._3dDescItem.dispose();
            this._3dDescItem = null;
            this._bg.dispose();
            this._bg = null;
            this._tipsTxt.dispose();
            this._tipsTxt = null;
            if (this._img2d)
            {
                this._img2d.dispose(true);
                this._img2d = null;
            }
            if (this._img2dTitle)
            {
                this._img2dTitle.dispose(true);
                this._img2dTitle = null;
            }
            if (this._contentBmd)
            {
                this._contentBmd.dispose();
                this._contentBmd = null;
            }
            if (this._roleModelPlayer)
            {
                this._rect3d.disposeObj3d(this._roleModelPlayer);
                this._roleModelPlayer = null;
            }
            if (this._rect3d)
            {
                Rect3DManager.instance.closeEndHander(null, this);
                this._rect3d = null;
            }
            this._wing288Data = null;
            return;
        }// end function

        private function drawTitle() : void
        {
            if (this._isDisposed || this._titleBg.bitmapData == null || this._tipsTxt.bitmapData == null)
            {
                return;
            }
            if (this._rect3d)
            {
                if (this._img2dTitle)
                {
                    this._img2dTitle.dispose(true);
                }
                this._contentBmd = new BitmapData(this._contentTopOf3DSprite.width, this._contentTopOf3DSprite.height, true, 16777215);
                this._contentBmd.draw(this._contentTopOf3DSprite);
                this._img2dTitle = new Img2D(null, this._contentBmd, new Rectangle(0, 0, this._contentBmd.width, this._contentBmd.height), true);
                this._img2dTitle.autoDispose = false;
                this._img2dTitle.x = 10;
                this._img2dTitle.y = 0;
                this._rect3d.addImg(this._img2dTitle, Layer3DManager.particleLayer);
            }
            return;
        }// end function

        private function update3DModule() : void
        {
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            var _loc_4:ItemData = null;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_1:* = new Rectangle(this._3dBgx + 10, this._3dBgy + paddingTop + 7, 350, 400);
            this._rect3d = Rect3DManager.instance.registerWindow(true, _loc_1, this, true);
            Rect3DManager.instance.windowShowHander(null, this);
            if (this._3dBg.bitmapData)
            {
                if (this._img2d)
                {
                    this._img2d.dispose(true);
                }
                this._img2d = new Img2D(null, this._3dBg.bitmapData, new Rectangle(0, 0, 350, 400), false);
                this._img2d.autoDispose = false;
                this._img2d.x = 0;
                this._img2d.y = 0;
                this._rect3d.addImg(this._img2d);
            }
            if (this._rect3d)
            {
                _loc_2 = -265;
                _loc_3 = 330;
                _loc_4 = new ItemData(this._wing288Data.code);
                if (this._roleModelPlayer == null)
                {
                    this._roleModelPlayer = FrObjectPool.getObject(UserModelPlayer, this);
                }
                _loc_5 = Cache.instance.role.entityInfo.career;
                _loc_6 = Cache.instance.role.entityInfo.sex;
                _loc_7 = 0;
                _loc_8 = 0;
                this._roleModelPlayer.updateIsShowEffect(true, true, true);
                this._roleModelPlayer.updateInfo(_loc_5, _loc_6, Cache.instance.role.roleEntityInfo.clothes, 0, _loc_7, (_loc_4.itemInfo as ItemEquipInfo).modelId, _loc_8, Cache.instance.role.roleEntityInfo.isHideWing);
                this._roleModelPlayer.scaleAll = 1.8;
                this._roleModelPlayer.rotationX = 0;
                this._roleModelPlayer.rotationY = 0;
                this._roleModelPlayer.useLight();
                this._roleModelPlayer.setRenderList(this._rect3d.renderList);
                this._rect3d.addObject3d(this._roleModelPlayer, 124 + 314 + _loc_2, _loc_3);
            }
            this._titleBg.imgUrl = ImagesConst.VipPanelRewardTitleBg;
            this._tipsTxt.imgUrl = ImagesConst.Wing288Txt_1;
            return;
        }// end function

        public function updatePosition() : void
        {
            this.dispatchEvent(new WindowEvent(WindowEvent.POSITIONCHANGE));
            return;
        }// end function

    }
}
